package com.diannuo.springboot.model;

public class Result implements java.io.Serializable{

    /**
     * 接口是否成功
     */
    private boolean success;
    /**
     * 状态码
     */
    private int code;
    /**
     * 说明
     */
    private String msg;
    /**
     * 数据对象
     */
    private Object data;

    public <T> Result(boolean success) {
        this.success = success;
        this.data = success ? (T) "" : null;
        this.code = success ? 0 : -1;
        this.msg = "";
    }

    public <T> Result(boolean success, int code, String msg, T data) {
        this.success = success;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public <T> T getData() {
        return (T) data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
